//
//  WZPLoginRegisterController.m
//  
//
//  Created by 王王喆平 on 16/7/8.
//
//

#import "WZPLoginRegisterController.h"
#import "WZPLoginRegisterView.h"
#import "WZPDrippleView.h"

@interface WZPLoginRegisterController ()
@property (weak, nonatomic) IBOutlet UIView *MIdView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *leading;
@property (weak, nonatomic) IBOutlet UIView *drippleView;

@end

@implementation WZPLoginRegisterController
// 点击X 返回
- (IBAction)closeBtn:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}
// 点击注册按钮 调整注册界面
- (IBAction)registerBtn:(UIButton *)sender {
    sender.selected = !sender.selected;
   // 点击切换到 注册界面,再次点击切换回来
//    if (_leading.constant == 0) {
//        _leading.constant = -WZPScreenW;
//    }else if (_leading.constant == -WZPScreenW){
//        _leading.constant = 0;
//    }
    _leading.constant = _leading.constant == 0 ? -WZPScreenW :0;
    
    [UIView animateWithDuration:0.3 animations:^{
        // 约束动画 苹果规定
        [self.view layoutIfNeeded];
    }];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    WZPLoginRegisterView * loginView = [WZPLoginRegisterView loginView];
    [_MIdView addSubview:loginView];
    
    WZPLoginRegisterView *registerView = [WZPLoginRegisterView registerView];
    registerView.wzp_x = _MIdView.wzp_width * 0.5;
    [_MIdView addSubview:registerView];
    
    WZPDrippleView * drippleView = [WZPDrippleView drippleView];
    [_drippleView addSubview:drippleView];
    
}
// 当前约束已完成,设置界面的frame
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    WZPLoginRegisterView *loginView = _MIdView.subviews[0];
    loginView.frame = CGRectMake(0, 0, _MIdView.wzp_width * 0.5, _MIdView.wzp_height);
    
    WZPLoginRegisterView * registerView = _MIdView.subviews[1];
    registerView.frame = CGRectMake(_MIdView.wzp_width * 0.5, 0, _MIdView.wzp_width * 0.5, _MIdView.wzp_height);
    
    WZPDrippleView * dippleView = _drippleView.subviews[0];
    dippleView.frame = CGRectMake(0, 0, _drippleView.wzp_width, _drippleView.wzp_height);

}


@end
